package logic

import (
	"cart_srv/cathe"
	"context"

	"cart_srv/cart"
	"cart_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartListLogic {
	return &CartListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartListLogic) CartList(in *cart.CartListRequest) (*cart.CartListResponse, error) {
	list, err := cathe.CartList(int(in.UserId))
	if err != nil {
		return nil, err
	}

	return &cart.CartListResponse{
		List: list,
	}, nil
}
